% key words: Lattice, panel, tight subplots, no gap, matrix, trellis, plot
% arrays

% sp1 = subplot(2,2,1);
% plot(1:10,(1:10).^2/9);
% sp2 = subplot(2,2,2);
% plot(1:10,(1:10).^.2/9);
% pos1 = get(sp1,'Position');
% pos2 = get(sp2,'Position');
% set(sp2,'Position',[pos1(1)+pos1(3) pos1(2) pos2(3) pos2(4)])
% % subplot('Position',[left bottom width height])



cfs = [10 20 30 40 50 60 70 80];
fs = 22050;                 % sample frequency (Hz)
d = 1.0;                    % duration (s)
n = fs * d;                 % number of samples
t = (1:n) / fs;             % sound data preparation
for i=1:length(cfs)
   stim(:,i) = sin(2 * pi * cfs(i) .* t); 
end



close('all')
fh = figure(1)
subplot1(2,4,'Gap',[0,0]) 
plot_num = 0; 
for j=1:2 
	for i=1:4 
        plot_num = plot_num + 1; 
        subplot1(plot_num); 
        %plot(randn(100,1),randn(100,1),'k.') 
        plot(t,stim(:,i+(4*(j-1))))
        
        text(995,0.5,[num2str(i+(4*(j-1))) ' ( ' num2str(i) ' - ' num2str(j) ')' ]);

        %axis([990 1010 0 1]) 
        axis([0 1 -1.5 1.5])
        
        tmp=get(gca,'xtick');
        set(gca,'xtick',[.3:.3:tmp(end)])
        
        
        % set(gca,'ytick',[-1.5:.3:1.5])

        
        if mod(i,2) == 0
            disp([num2str(i) ' - ' num2str(j)])
            set(gca,'XTick',[]) 
        end
        %axis square 
    end 
end

set(fh,'Position',[300 300 400 200]) 

sdfdf


% this removes the excessive figure margins, and makes figures nice to
% import into documents without having to crop.
set(gca,'LooseInset',get(gca,'TightInset'))